<template>
	<view class="w-100">
		<view class="flex-1 mx-3">
			<view class="flex-1 py-3 border-bottom" v-for="(item, index) in  workreportList" :key="index">
				<view class="d-f justify-between" @click="reportDetails(item.id)">
					<view class="">
						<view class="font-s-35 font-w-600">{{ item.title }}</view>
						<view class="font-s-2 text-muted">{{ item.created_time }}</view>
					</view>
					<view class="font-s-2 text-muted">
						<text v-if="item.is_read == true">已阅读</text>
					</view>
				</view>
			</view>
		</view>
		<view class="add-report row-a-j-fc" @click="toAddReport">
			<view class="iconfont icon-delt2-01"></view>
			<view class="font-s-1">写报告</view>
		</view>
	</view>
</template>

<script>
	import {
	  workreportListUrl
	} from '@/api/index.js';
	export default {
		data(){
			return{
				queryInfo: {
					page: 1,
					page_size: 12
				},
				workreportList:[]
			}
		},
		onLoad() {
			this.getWorkreportList()
		},
		onShow() {
			this.getWorkreportList()
		},
		methods:{
			getWorkreportList() {
				this.$R.get(workreportListUrl, this.queryInfo).then(res => {
					if(res.code == 200){
						this.workreportList = res.data.list
						this.workreportTotal = res.data.total
					}
				})
			},
			reportDetails(reportId){
				uni.navigateTo({
					url: '/pages/user/workreport/report-details?reportId=' + reportId,
				});
			},
			toAddReport(){
				uni.navigateTo({
					url: '/pages/user/workreport/app-report',
				});
			}
		}
	}
</script>

<style lang="scss">
	.add-report{
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;
		position: fixed;
		bottom: 100rpx;
		right: 30rpx;
		box-shadow: 2rpx 2rpx 8rpx #999;
		background-color: rgba(255,255,255, .6);
	}
</style>